// 管理员相关api
import apiClient from './index'

export const adminApi = {
    // 用户管理
    getUsers(params) {
        return apiClient.get('/admin/users', { params })
    },

    createUser(userData) {
        return apiClient.post('/admin/users', userData)
    },

    updateUser(userId, userData) {
        return apiClient.put(`/admin/users/${userId}`, userData)
    },

    deleteUser(userId) {
        return apiClient.delete(`/admin/users/${userId}`)
    },

    // 企业审核
    getPendingCompanies() {
        return apiClient.get('/admin/companies/pending')
    },

    reviewCompany(companyId, reviewData) {
        return apiClient.put(`/admin/companies/${companyId}/review`, reviewData)
    },

    // 实习申请管理
    getAllApplications() {
        return apiClient.get('/admin/applications')
    },

    processApplication(applicationId, processData) {
        return apiClient.put(`/admin/applications/${applicationId}/process`, processData)
    },

    // 实习材料管理
    getAllMaterials() {
        return apiClient.get('/admin/materials')
    },

    reviewMaterial(materialId, reviewData) {
        return apiClient.put(`/admin/materials/${materialId}/review`, reviewData)
    },

    // 数据统计
    getInternshipStatistics() {
        return apiClient.get('/admin/statistics/internship')
    },

    getSystemStatistics() {
        return apiClient.get('/admin/statistics/system')
    },
    // 实习岗位管理
    getInternshipPositions(params) {
        return apiClient.get('/internship-positions', { params })
    },

    // 实习管理
    getInternships(params) {
        return apiClient.get('/internships', { params })
    },

    // 添加以下新接口
    updateStudent(userId, studentData) {
        return apiClient.put(`/admin/students/${userId}`, studentData)
    },

    updateTeacher(userId, teacherData) {
        return apiClient.put(`/admin/teachers/${userId}`, teacherData)
    },

    updateCompany(userId, companyData) {
        return apiClient.put(`/admin/companies/${userId}`, companyData)
    },
    getUserDetail(userId) {
        return apiClient.get(`/admin/users/${userId}/detail`)
    },
    togglePositionStatus(positionId) {
        return apiClient.put(`/internship-positions/${positionId}/admin-toggle-status`)
    },
    // 获取教师列表
    getTeachers() {
        return apiClient.get('/admin/teachers');
    },
    // 分配指导教师
    assignTeacher(internshipId, teacherId) {
        return apiClient.put(`/internships/${internshipId}/assign-teacher`, null, {
            params: {
                teacherId: teacherId
            }
        });
    },

    // 更新企业导师信息
    updateMentorInfo(internshipId, mentorData) {
        return apiClient.put(`/internships/${internshipId}/mentor-info`, null, {
            params: {
                mentorName: mentorData.mentorName,
                mentorPhone: mentorData.mentorPhone,
                mentorEmail: mentorData.mentorEmail
            }
        });
    }
}
